package org.hako.recite.word.tool;

import java.util.Comparator;

/**
 * Comparator for {@link KannjiYomiPair}.
 * 
 * @since 0.4.14
 * @author <a href="mailto:xnnyygn@gmail.com">xnnyygn</a>
 */
public class KannjiYomiPairComparator implements Comparator<KannjiYomiPair> {

	@Override
	public int compare(KannjiYomiPair pair1, KannjiYomiPair pair2) {
		int kannjiCompareResult = pair1.getKannji()
				.compareTo(pair2.getKannji());
		if (kannjiCompareResult == 0) {
			return pair1.getYomi().compareTo(pair2.getYomi());
		}
		return kannjiCompareResult;
	}

}
